<template>
  <div class="shopinfor">
    <Loading v-if="isloading"></Loading>
    <div class="main">
      <div class="top">
        <div class="t1">
          <div>
            <img
              class="img1"
              :src="'https://elm.cangdu.org/img/' + list.image_path"
              alt=""
            />
          </div>
          <div class="ti_text">
            <h3>{{ list.name }}</h3>
            <div class="_center">
              商家配送／分钟送达／配送费¥{{ list.float_delivery_fee }}
            </div>

            <div class="_bottom">公告:{{ list.promotion_info }}</div>
          </div>
        </div>

        <div class="t2">
          <span class="jian">{{ list.activities[0].icon_name }}</span>
          <span class="msg"
            >{{ list.activities[0].description }}（APP专享）</span
          >
        </div>
      </div>

      <div class="mid">
        <ul class="ul_1">
          <li
            :class="{ select: sele == index }"
            @click="btn(index)"
            v-for="(item, index) in datas"
            :key="index"
          >
            {{ datas[index].name }}
          </li>
        </ul>
      </div>
      <div class="bg">
        <img
          class="img2"
          src='"https://elm.cangdu.org/img/"+list.image_path'
          alt=""
        />
      </div>
    </div>
    <div>
      <router-view></router-view>
    </div>
  </div>
</template>
<script>
import Vue from "vue";
import Loading from "../compoents_B/Loading";
import { Sidebar, SidebarItem } from "vant";

Vue.use(Sidebar);
Vue.use(SidebarItem);

export default {
  components: {
    Loading,
  },
  data: function () {
    return {
      list: [],
      list2: [],
      shuju: JSON.parse(localStorage.getItem("shuju")),
      sele: 0,
      activeKey: 0,
      datas: [
        {
          name: "商品",
        },
        {
          name: "评价",
        },
      ],
      isLoading: true,
    };
  },
  methods: {
    btn(index) {
      this.sele = index;
      if (index == 1) {
        this.$router.push({ name: "Evaluate" });
      } else if (index == 0) {
        this.$router.push({ name: "Shangpin" });
      }
    },
  },
  created() {
    this.$axios
      .get(`https://elm.cangdu.org/shopping/restaurant/${this.shuju}`, {})
      .then((res) => {
        // console.log(res)
        // console.log('//////')
        // 获取对应的数据
        this.list = res;
        this.isloading = false;
      }),
      this.$axios
        .get(
          `https://elm.cangdu.org/shopping/v2/menu?restaurant_id=${this.shuju}`,
          {}
        )
        .then((res) => {
          //console.log(res)
          // 获取对应的数据
          this.list2 = res;
        });
  },
};
</script>
<style lang="less">
.van-sidebar-item--select::before {
  height: 100% !important;
  background-color: #3190e8 !important;
}
.list {
  width: 98px;
  height: 72px;
}
.select {
  border-bottom: 4px solid #3190e8;
  // padding-bottom: 5px;
  // box-sizing: border-box;
}

.ul_1 {
  display: flex;
  text-align: center;
  box-sizing: border-box;
  padding-top: 15px;
  justify-content: space-around;
}

.mid {
  width: 100%;
  height: 59.2px;
  font-size: 17px;
  background-color: white;
}
.top {
  padding: 10px;
  background-color: rgba(119, 103, 137, 0.43);
  .t1 {
    width: 100%;
    display: flex;
    justify-content: space-between;

    img {
      width: 75px;

      border-radius: 0.15rem;
    }
    .ti_text {
      width: 320px;
      margin-left: 10px;
      h3 {
        color: #fff;
        font-weight: 700;
        margin-bottom: 0.3rem;
      }
      ._center {
        font-size: 0.5rem;
        color: #fff;
        margin-bottom: 0.3rem;
      }
      ._bottom {
        font-size: 0.5rem;
        color: #fff;
        width: 100%;
        overflow: scroll;
      }
    }
  }
  .t2 {
    box-sizing: border-box;
    padding: 5px 0;
    .jian {
      background-color: rgb(240, 115, 115);
      border-color: rgb(240, 115, 115);
      font-size: 0.8rem;
    }
    .msg {
      color: #fff;
      font-size: 0.5rem;
    }
  }
}

.img2 {
  width: 100%;
  position: absolute;
  top: 64px;
  left: 0;
  filter: blur(10px);
  z-index: -9;
}

.evaluate {
  margin-left: 100px;
  margin-top: 200px;
}
</style>